import { fileURLToPath, URL } from 'node:url'
import { resolve } from "path";
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  // plugins: [vue()],
  optimizeDeps: {
    exclude: ["electron"],
  },
  //vite add plugins
  plugins: [
    vue(),
  ],
  resolve: {
    alias: {
      "@": resolve(__dirname, "./src"),
      "*": resolve(""),
    },
    extensions: [".tsx", ".ts", ".js", ".jsx"],
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "./src/theme/theme.scss" as *;`,
      },
      less: {
        modifyVars: {
          "primary-color": "#4F8FEB",
          "link-color": "#4F8FEB",
          "border-radius-base": "2px",
          "border-color-base": "#ddd",
        },
        javascriptEnabled: true,
      },
    },
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    },
    host: "0.0.0.0",
    port: 8080,
    open: true,
  }
})
